
const state = {
  anyDeviceStatus: null,
  anyDeviceGPS: null,
  	//聊天消息
	chatMessageStr:null,
}

const mutations = {
  HAVE_DEVICE_STATUS_CHANGE: (state, data) => {
    state.anyDeviceStatus = data
  },
  HAVE_DEVICE_GPS_CHANGE: (state, data) => {
    state.anyDeviceGPS = data
  },
  SET_MESSAGE(state, messageResult) {
    state.chatMessageStr = messageResult;
  }
}

const actions = {
  haveDeviceStatusChange({ commit }, data) {
    commit('HAVE_DEVICE_STATUS_CHANGE', data)
  },
  haveDeviceGPSChange({ commit }, data) {
    commit('HAVE_DEVICE_GPS_CHANGE', data)
  },

  //此处编写使用 this.$store.dispatch()方法时的配置
  setMessage(context, value) {
    console.log("context--》", context);
    console.log("value--》", value);

    if (value != null && value != '') {

      let messageResult = JSON.parse(value);
      console.log("messageResult--》", messageResult);
      context.commit('SET_MESSAGE', messageResult)

    }
  }

}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
